<?php

namespace App\Http\Controllers\Admin;

use App\Api\Serializer\CustomSerializer;
use App\Http\Controllers\BaseController;
use App\Http\Requests\Admin\ReportRequest;
use App\Models\Report;
use App\Transformers\ReportTransformer;
use Illuminate\Http\Request;

class ReportController extends BaseController
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $reports = Report::where('is_not_ok',0)->get();
        return $this->response->collection($reports,new ReportTransformer(),function ($resource, $fractal) {
            $fractal->setSerializer(new CustomSerializer());
        });
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
//    public function store(ReportRequest $request)
//    {
//        $user_id = auth('api')->user()->id;
//        if ($request->be_reported_user_id == $user_id){
//            $this->response->errorBadRequest();
//        }
//        $in = $request->all();
//        $in['user_id'] = $user_id;
//        Report::create($in);
//        return  $this->response->noContent();
//    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show(Report $report)
    {

        return $this->response->item($report,new ReportTransformer(),function ($resource, $fractal) {
            $fractal->setSerializer(new CustomSerializer());
        });
    }


}
